<template>
  <div class="pingjia">
    <!-- 这是订单评价页面 -->
    <!-- 书写标题头 -->
    <div class="order_title">
      <span class="one" @click="tuihou">&lt;</span>
      <span>评分</span>
    </div>
    <!-- 订单信息部分 -->
    <div class="cont_one">
      <div class="cont_tit">
        <van-icon name="orders-o" />
        <span>订单信息</span>
      </div>
      <div class="cont_body">
        <ul>
          <li>
            <span>商品</span>
            <span>{{ contVal.prodName }}</span>
          </li>
          <li>
            <span>发货时间</span>
            <span>{{ contVal.sendTime }}</span>
          </li>
          <li>
            <span>到达时间</span>
            <span>{{ contVal.receiveTime }}</span>
          </li>
        </ul>
      </div>
    </div>
    <!-- 服务评价部分 -->
    <div class="cont_two">
      <div class="cont_tit">
        <van-icon name="orders-o" />
        <span>服务评价</span>
      </div>
      <!-- 评价的具体模块 -->
      <div class="pingfen">
        <div class="Ping_list">
          <span>描述相符</span>
          <ul>
            <li
              v-for="(item, index) in 5"
              :key="index"
              @click="change_col1(index)"
            >
              <img
                :src="index <= prodConformityPoint - 1 ? srcImgTwo : srcImgOne"
                alt=""
              />
            </li>
          </ul>
          <span>{{ prodConformityPoint * 2 }}分</span>
        </div>
        <div class="Ping_list">
          <span>描述相符</span>
          <ul>
            <li
              v-for="(item, index) in 5"
              :key="index"
              @click="change_col2(index)"
            >
              <img
                :src="
                  index <= logisticsSpeedPoint - 1 ? srcImgThree : srcImgOne
                "
                alt=""
              />
            </li>
          </ul>
          <span>{{ logisticsSpeedPoint * 2 }}分</span>
        </div>
        <div class="Ping_list">
          <span>描述相符</span>
          <ul>
            <li
              v-for="(item, index) in 5"
              :key="index"
              @click="change_col3(index)"
            >
              <img
                :src="index <= serviceQualityPoint - 1 ? srcImgFour : srcImgOne"
                alt=""
              />
            </li>
          </ul>
          <span>{{ serviceQualityPoint * 2 }}分</span>
        </div>
      </div>
    </div>
    <!-- 输入评论模块 -->
    <textarea name="" id="" v-model="pinglunVal"></textarea>
    <!-- 提交评论的按钮 -->
    <div class="cont_btn">
      <van-button type="info" size="large" @click="pinglun_btn"
        >确认发货消息</van-button
      >
    </div>
  </div>
</template>

<script>
import { GetOrderXiangQing, TiJiaoPingLun } from "@/request/api";
export default {
  data() {
    return {
      // 星星的样式
      srcImgOne: require("@/assets/pingfen-hui.png"),
      srcImgTwo: require("@/assets/pingfen-huang.png"),
      srcImgThree: require("@/assets/pingfen-cheng.png"),
      srcImgFour: require("@/assets/pingfen-hong.png"),
      contVal: "",
      //  评价点亮星星的三个分数
      prodConformityPoint: "0",
      logisticsSpeedPoint: "0",
      serviceQualityPoint: "0",
      pinglunVal: "",
    };
  },
  created() {
    console.log(this.$route.query.id);

    GetOrderXiangQing({
      serialNo: this.$route.query.id,
    }).then((res) => {
      console.log(res.data);
      this.contVal = res.data;
    });
  },
  methods: {
    //   计算三列星星的分数
    change_col1(val) {
      //   console.log(val);
      this.prodConformityPoint = val + 1;
      console.log(this.prodConformityPoint);
    },
    change_col2(val) {
      //   console.log(val);
      this.logisticsSpeedPoint = val + 1;
      console.log(this.logisticsSpeedPoint);
    },
    change_col3(val) {
      //   console.log(val);
      this.serviceQualityPoint = val + 1;
      console.log(this.serviceQualityPoint);
    },
    // 发送请求，提交评论
    pinglun_btn() {
      TiJiaoPingLun({
        serialNo: this.$route.query.id,
        prodConformityPoint: this.prodConformityPoint,
        logisticsSpeedPoint: this.logisticsSpeedPoint,
        serviceQualityPoint: this.serviceQualityPoint,
        comment: this.pinglunVal,
      }).then((res) => {
        console.log(res);
      });
    },
    //点击返回按钮，回到上一个页面
    tuihou(){
        this.$router.go(-1)
    }
  },
};
</script>
 
<style lang = "less" scoped>
/* 页面的总样式 */
.pingjia {
  min-height: 100%;
  width: 100%;
  background-color: #efefef;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 4;
  /* 标题头的样式 */
  .order_title {
    width: 100%;
    height: 0.5rem;
    background-color: #003399;
    text-align: center;
    line-height: 0.5rem;
    color: white;
    font-size: 0.18rem;
    padding-top: 0.1rem;
    .one {
      float: left;
      margin-left: 0.2rem;
    }
  }
  /* 订单信息的样式 */
  .cont_one {
    width: 100%;
    background-color: white;
    .cont_tit {
      width: 100%;
      background-color: #f5fafe;
      padding: 0.1rem 0.2rem;
      font-size: 0.16rem;
      color: #003399;
    }
    .van-icon {
      vertical-align: -0.02rem;
      margin-right: 0.1rem;
    }
    /* 商品信息样式 */
    .cont_body {
      width: 100%;
      padding: 0.2rem;
      box-sizing: border-box;
      background-color: white;
      ul {
        li {
          line-height: 0.2rem;
          display: flex;
          justify-content: space-between;
          span {
            &:nth-child(1) {
              flex: 2;
              color: #aaa;
            }
            &:nth-child(2) {
              flex: 10;
            }
          }
        }
      }
    }
  }
  /* 服务评价部分样式 */
  .cont_two {
    width: 100%;
    background-color: white;
    margin-top: 0.1rem;
    /* 标题的样式 */
    .cont_tit {
      width: 100%;
      background-color: #f5fafe;
      padding: 0.1rem 0.2rem;
      font-size: 0.16rem;
      color: #003399;
    }
    .van-icon {
      vertical-align: -0.02rem;
      margin-right: 0.1rem;
    }
    .pingfen {
      width: 100%;
      padding: 0 0.2rem;
      box-sizing: border-box;
      .Ping_list {
        display: flex;
        line-height: 0.2rem;
        line-height: 50px;
        justify-content: space-between;
        border-bottom: 1px solid #ddd;
        ul {
          li {
            float: left;
            margin-right: 0.05rem;
            height: 0.5rem;
            vertical-align: center;
            img {
              height: 0.3rem;
              margin-top: 10px;
            }
          }
        }
      }
    }
  }
  /* 输入评论样式 */
  textarea {
    width: 100%;
    border: 0;
    margin-top: 0.1rem;
    height: 1rem;
  }
  /* 提交评论按钮样式 */
  .cont_btn {
    position: fixed;
    bottom: 0;
    height: 0.6rem;
    width: 100%;
    background-color: white;
    padding: 0 0.2rem;
    box-sizing: border-box;
    .van-button {
      border-radius: 0.25rem;
      margin-top: 0.05rem;
    }
  }
}
</style>